home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CU Amiga Super CD-ROM 12
/
CU Amiga Magazine's Super CD-ROM 12 (1997)(EMAP Images)(GB)[!][issue 1997-07].iso
/
System
/
CDsupport
/
IDer
/
Routines
/
ProcessOffset.s
< prev
next >
Wrap
Text File
|
1997-02-18
|
3KB
|
102 lines
ProcessOffset: Move.L _Offset(PC),A0 ;was the annoying option included?
Cmp.L #0,A0
Beq .NoOffset
Lea WorkData,A1
Moveq #0,D0
.OffsetCopy Move.B (A0)+,D0 ;we need to get all the numbers before the comma
Beq .BadOffset ;and put them elsewhere where we can work with them
Move.B D0,(A1)+
Cmp.B #',',D0 ;the comma is the seperator
Bne.S .OffsetCopy
Clr.B -1(A1) ;mark the end of the offset
Move.L A0,A3 ;data after comma
Move.L #WorkData,D1
Move.L #_OffsetVal,D2
CALL StrToLong,DOS ;convert a decimal string into a longword
Cmp.L #-1,D0
Beq .BadOffset
Move.L _FileData(PC),A0 ;start of the data from our file to load
Move.L _OffsetVal(PC),D0 ;how far into the do we need to go
Lea (A0,D0.w),A4 ;move to it
Move.B (A3),D0
Cmp.B #'"',D0 ;are the characters an ASCII string, instead of a sequence of hex
Bne.S .OffsetLoop2 ;if not, go process the hex
Move.L A3,A0
Lea WorkData,A1 ;copy the string elsewhere
Bsr StripQuotes ;removing the quotes around it as we go
Lea WorkData,A0
.OffsetLoop Moveq #0,D0
Moveq #0,D1
Move.B (A0)+,D0 ;get a character of the string
Beq.S .OffsetDone ;if it's zero, then the check has worked
Move.B (A4)+,D1 ;data file
Tst.B _Insensitive ;are we caring about case sensitivity?
Beq.S .NoInsensitive ;if so, then skip the routines to convert to uppercase
Bsr ChangeCase ;convert the OFFSET character
Exg.L D1,D0 ;swap the two characters over
Bsr ChangeCase ;convert the data from the file
Exg.L D1,D0 ;swap the two characters over
.NoInsensitive Cmp.B #'?',D0 ;is it a wildcard?
Beq.S .OffsetLoop ;if so, then skip the comparison
Cmp.B D0,D1 ;compare the two characters
Beq.S .OffsetLoop ;if they are the same, then continue the check
Bra.S .BadOffset ;if they are different, then stop checking with this class
.OffsetLoop2 Moveq #0,D0
Moveq #0,D1
Move.B (A3)+,D0 ;get a character of the string
Beq.S .OffsetDone
Cmp.B #'.',D0 ;is a skip character
Bne.S .NotSkip
Addq #1,A3 ;jump over the second '.'
Addq #1,A4 ;jump over the byte in the datafile
Bra.S .OffsetLoop2
.NotSkip Bsr ChangeCase ;the user may type the hex in upper or lower case
Move.B D0,D1
Sub.B #48,D1 ;drop ascii back to decimal
Cmp.B #10,D1
Blt.S .NotHex
Subq #7,D1 ;drop hex back into base 10
.NotHex Lsl.W #4,D1 ;we have the 10's column
Move.B (A3)+,D0 ;get the second part of the hex number
Bsr ChangeCase
Sub.B #48,D0 ;remove Ascii coding
Cmp.B #10,D0
Blt.S .NotHex2
Subq #7,D0 ;make hex into decimal
.NotHex2 Add.B D0,D1 ;build the final number
Move.B (A4)+,D0 ;get the character to compare out of the data file
Tst.B _Insensitive ;are we caring about case sensitivity?
Beq.S .NoInsensitive2 ;if so, then skip the routines to convert to uppercase
Bsr ChangeCase ;convert the OFFSET character
Exg.L D1,D0 ;swap the two characters over
Bsr ChangeCase ;convert the data from the file
Exg.L D1,D0 ;swap the two characters over
.NoInsensitive2
Cmp.L D0,D1 ;are they the same
Beq.S .OffsetLoop2 ;if so, check the next character
Bra.S .BadOffset
.OffsetDone
Addq.B #1,_Successful
Cmp.B #MODE_ONE,_Mode
Beq.S LaunchAction
Bra.S .NoOffset
.BadOffset Cmp.B #MODE_ALL,_Mode
Beq CheckLoop
.NoOffset